const express = require('express')
const routerList = express.Router()
const jsonwebtoken = require('../utils/jsonwebtoken')
const { Success, Error } = require('../utils/baseModel')
const { getList } = require('../db/dbList')
//获取数据
routerList.get('/list', async (req, res, next) => {
    try {
        const token = req.headers['authorization'];
        const returnToken = await jsonwebtoken.decodeToken(token)
        if (returnToken.error) {
            res.send(new Error({ message: 'token过期了' }))
        } else {
           const listData=await getList()
            res.send(new Success({ message: listData }))
        }
    } catch (error) {
        res.send(new Error({ message: error }))
    }
})
module.exports = routerList